package me.sauce.bitcoinwallet;

import org.junit.Assert;
import org.junit.Test;

import java.util.Base64;

import me.sauce.bitcoinwallet.key.utils.RandomUtils;

import static me.sauce.bitcoinwallet.key.utils.RandomUtils.rawEntropyToWords;

/**
 * @author sauce
 * @since 2018/4/3
 */
public class KeyUtils {
    @Test
    public void genKey() {
        RandomUtils randomUtils = new RandomUtils();
        byte[] rawEntropy = new byte[256 / 8];
        randomUtils.nextBytes(rawEntropy);
        String encoded = Base64.getEncoder().encodeToString(rawEntropy);
        System.out.print(encoded + "\n");
        String[] wordList = rawEntropyToWords(rawEntropy);
        System.out.print(wordList.length + "\n");
        for (String s : wordList) {
            System.out.print(s + "-");
        }
        byte[] s = RandomUtils.wordListToBytes(wordList);
         encoded = Base64.getEncoder().encodeToString(s);
        System.out.print("\n"+encoded  );
//        Assert.assertArrayEquals(rawEntropy, s);
    }
}
